#include "all2.h"
#include "saveur.cpp"
#include "./UCT/noeudUCT.h"




Piece poToPiece (Po piece){
    if(piece.orient == HAUT){
        return piece.p;
    } else {
        Piece pTemp;
        pTemp.numero = piece.p.numero;
        pTemp.estPose = piece.p.estPose;

        if(piece.orient == BAS){
            pTemp.haut = piece.p.bas;
            pTemp.bas = piece.p.haut;
            pTemp.gauche = piece.p.droit;
            pTemp.droit = piece.p.gauche;
        }
        else if(piece.orient == GAUCHE){
            pTemp.haut = piece.p.droit;
            pTemp.bas = piece.p.gauche;
            pTemp.gauche = piece.p.haut;
            pTemp.droit = piece.p.bas;
        }
        else if(piece.orient == DROIT){
            pTemp.haut = piece.p.gauche;
            pTemp.bas = piece.p.droit;
            pTemp.gauche = piece.p.bas;
            pTemp.droit = piece.p.haut;
        }
        return pTemp;
    }

}


Po coupToPo (Coup c){
    Po retour;
    retour.p = c.p;
    retour.orient = c.orientation;
    return retour;
}


Piece coupToPiece(Coup c){
    return poToPiece(coupToPo(c));
}

bool operator==(Coord c, Coord c2){
    return (c.x==c2.x && c.y == c2.y);
}

bool operator==(Piece p, Piece p2){
    return (p.numero==p2.numero && p.haut == p2.haut && p.bas== p2.bas && p.droit == p2.droit && p.gauche == p2.gauche);
}

bool operator==(Po c, Po c2){
    return (c.orient== c2.orient && c.p == c2.p);

}


bool operator==(Coup c, Coup c2){
    return (c.orientation== c2.orientation && c.place == c2.place && c.p == c2.p);

}


ostream &operator<<( ostream &out, Piece p )
{
        out << p.numero << ": " << (int)p.haut << " - " << (int)p.droit << " - "<< (int)p.bas<<" - "<<(int)p.gauche  ;
        return out;
}

ostream &operator<<( ostream &out, Coup c )
{
    Po temp =coupToPo(c);
    Piece p = poToPiece(temp);
    out<< p.numero << ": " << (int)p.haut << " - " << (int)p.droit << " - "<< (int)p.bas<<" - "<<(int)p.gauche<<" x: "<<(int)c.place.x<<" y: "<<(int)c.place.y<<endl;

}

ostream &operator<<( ostream &out, Coord c ){
    out<<(int)c.x<<" - "<<(int)c.y;
}


ostream &operator<<( ostream &out, noeudUCT &noeud  )
{
    noeud.afficher(out) ; // <- Changement ici
    return out;
}


Coord operator+( Coord c, Coord c2 ){
    Coord retour;
    retour.x = c.x + c2.x;
    retour.y = c.y + c2.y;
    return retour;
}
